package cn.jlonely.xyhx.admin.mapper;

import cn.jlonely.xyhx.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT user_id, username, nickname, real_name, college, grade, user_class, contact_info, avatar_url, create_time, update_time, sex, user_status " +
            "FROM users WHERE real_name LIKE CONCAT('%', #{name}, '%') ORDER BY create_time DESC")
    @Results({
            @Result(property = "id", column = "user_id")
    })
    List<User> getUserAll(String name);

    @Update("UPDATE users SET user_status = #{userStatus} WHERE user_id = #{id}")
    void updateUserStatus(Integer id, Integer userStatus);

    @Update("UPDATE users SET password = #{resetPassword} WHERE user_id = #{id}")
    void resetUserPassword(Integer id, String resetPassword);
}
